package com.allenkerr.job;

import com.allenkerr.GirlApplication;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * Created by 小柯 on 17/7/12.
 */
@Component
public class Scheduler {

    //每隔一秒执行一次
    /*@Scheduled(initialDelay = 500, fixedDelay = 1000)
    @Async
    public void test1() {
        System.out.println("Scheduler.test1");
    }*/

    //@Scheduled(initialDelay = 500, fixedDelay = 200)
    //@Scheduled(initialDelay = 500, fixedRate = 200)
    //@Async
    public void test2() {
        while (true) {
            System.out.println("Scheduler.test2");
            System.out.println("Scheduler.test2 ---> " + Thread.currentThread());
            try {
                Thread.sleep(200);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

}
